The current version of cphplib contains 63 functions.
All functions
are inside the class except isvoid. Also
two global variables exist named $WHITE_SPACE and $WHITE_DSPACE,
used for non-breakable-space and double-non-breakable-space.
| Syntax: | string addQuote (string str) |
| Options: | str = string to convert with_trim = if true, with trim function {default: true} |
| Return: | converted string |
| Description: | envelops a string with quotes (for db INSERT) |
| Syntax: | array array_sort ([array a, array b]) |
| Options: | a = keys b = values |
| Return: | sorted array |
| Description: | sort array (subfunction for usort) |
| Syntax: | array array_unique (array thearray]) |
| Options: | thearray = array to unique |
| Return: | new array without duplicated entries |
| Description: | Removes duplicate values from an array (this function is much slower than the internal php function, but it works correctly with php < 4.1.0) |
| Syntax: | char browser_type (void]) |
| Return: | m = Mozilla (and all clones) i = Internet Explorer n = Netscape o = Opera "" = unknown |
| Description: | returns type of browser |
| Syntax: | bool checkBlz (string blz) |
| Options: | blz = Bankleitzahl to validate |
| Return: | true if valid |
| Description: | validate German Bankleitzahl ( allowed seperators: "-", "." or " ") |
| Syntax: | bool checkEmail (string email [, bool with_dns]) |
| Options: | email = email address with_dns = true for dns check {default: false} |
| Return: | true if valid |
| Description: | validate email address format |
| Syntax: | bool checkFirstChar (string str) |
| Options: | str = string to validate |
| Return: | true if true |
| Description: | is first character a letter, number or hyphen? |
| Syntax: | bool checkHtmlTag (string str) |
| Options: | str = string to validate |
| Return: | true if string has html tags |
| Description: | check if a string has HTML tags |
| Syntax: | bool checkIP (string addr) |
| Options: | ip address to validate |
| Return: | true if valid |
| Description: | validate ip address |
| Syntax: | bool checkNumber (string number [, string sep]) |
| Options: | number = number to validate sep = valid seperator {default: "."} mode = if true, with negative numbers {default: true} |
| Return: | true if valid |
| Description: | is string a valid number? |
| Syntax: | bool checkNumWildcard (string number [, string sep]) |
| Options: | number = number to validate sep = valid seperator {default: ","} |
| Return: | true if valid |
| Description: | validate number (positiv) with wildcards |
| Syntax: | bool checkPassword (string password [, int min_length [, int mode]]) |
| Options: | password = password string min_lenth = minimal length of password {default: 5} mode = 1 = alpha-numeric characters 2 = alpha characters with "_" {default: 2} 3 = alpha-numeric characters + special characters (like generatePassword) 4 = alpha-numeric characters + at least one special characters (like generatePassword) |
| Return: | true for qualified password |
| Description: | validate password format |
| Syntax: | bool checkPhone (string number) |
| Options: | number = phone number to validate |
| Return: | true if valid |
| Description: | validate phone number |
| Syntax: | bool checkPHPVersion (string min_ver [, with_pear]) |
| Options: | min_ver = oldest php version, which is allowed with_pear = true if pear must installed {default: false} mode = if true die with message {default: false} |
| Return: | true for qualified php version |
| Description: | checks version of php and if pear is installed |
| Syntax: | bool checkSpecialIndex (string str) |
| Options: | str = string to validate |
| Return: | true if valid |
| Description: | index for list: special characters |
| Syntax: | bool checkString (string str [, bool mode]) |
| Options: | str = string to validate mode = true for German Umlaute include {default: false} |
| Return: | true if valid |
| Description: | validate string with letters only |
| Syntax: | bool checkURL (string url [,bool mode]) |
| Options: | url = url to validate mode = if true, protocol is requiered {default: false} |
| Return: | true if valid |
| Description: | validate URL format (with or without protocol prefix) |
| Syntax: | bool checkUserName (string str [, int min_length]) |
| Options: | str = user to validate min_length = minimal length of username {default: 3} |
| Return: | true if valid |
| Description: | validate user name |
| Syntax: | bool checkZip (string zip) |
| Options: | zip = zip to validate |
| Return: | true if valid |
| Description: | validate post zip code |
| Syntax: | string convDate (string date_str, string date_old, string date_new) |
| Options: | date_str = date to validate date_new = see member variables m_lang below date_old = see member variables m_lang below |
| Return: | date or {if wrong input) empty |
| Description: | convert date format |
| Syntax: | string convDateWildcard (string date_str, string wildcard) |
| Options: | data_str = date with wildcards wildcard = wildcard character {default: "*"} |
| Return: | date |
| Description: | convert date with wildcards |
| Syntax: | string convFirstLetter (string str [, bool mode]) |
| Options: | str = string to convert mode = true for upper, false for lower} |
| Return: | converted string |
| Description: | convert first letter to upper or lower |
| Syntax: | string convHtml (string str [, bool mode]) |
| Options: | str = string to convert mode = true for html->ascii {default: false} with_trim = if true, with trim function {default: true} |
| Return: | converted string |
| Description: | convert ascii string to HTML string (because of a bug, it is better to set magic_quotes_gpc=Off in your php.ini) |
| Syntax: | string convnumSep (string value [, string sep_new [, int precision]]) |
| Options: | value = number to convert sep_new = new seperator {default: "."} precision = numbers behind seperator {default: 0 } (filling with 0; this function doesn't cut or round numbers) |
| Return: | converted string with number |
| Description: | convert seperator in number and fill number to specified length |
| Syntax: | float convTax (string tax) |
| Options: | tax to convert |
| Return: | converted tax |
| Description: | convert tax integer to percent |
| Syntax: | string convTime (string time [, string format]) |
| Options: | time = time to convert format = see member variable m_time below |
| Return: | converted time, if wrong input false |
| Description: | validate time format and convert it into right format |
| Syntax: | float convtoNum (string value [, string sep_old]) |
| Options: | value = string to convert {default: ","} sep_old = old seperator |
| Return: | converted number |
| Description: | convert string to number while converting old seperator with "." |
| Syntax: | string convtoTimestamp ([string time [, string format]]) |
| Options: | time = time (or date) to convert, if empty NOW will be used format = if empty or time, e.g. 19:45:59 datetime, e.g. 2002-07-20 21:02:55 |
| Return: | converted time, if wrong input false |
| Description: | validate time format and convert it into right format |
| Syntax: | string convUrl (string url) |
| Options: | url = url |
| Return: | converted url |
| Description: | checks for protocol, if missing http will be used |
| Syntax: | int countdown (string enddate) |
| Options: | enddate |
| Return: | days till specified date |
| Description: | counts days till specified day |
| Syntax: | int cross_sum (string number) |
| Options: | number = integer number |
| Return: | cross sum |
| Description: | calculates cross sum |
| Syntax: | string currentDate ([string format]) |
| Options: | format = see member variables m_lang below |
| Return: | current date |
| Description: | the current date |
| Syntax: | string currentTime ([string format]) |
| Options: | format = see member variable m_time below |
| Return: | current time |
| Description: | the current time |
| Syntax: | int currentWeek ([string locale]) |
| Options: | locale to use (see "man locale") {default: de_DE} |
| Return: | current week number |
| Description: | the current week |
| Syntax: | int dateClean (string date_str [, format]) |
| Options: | date_str = date to remove seperator format = see member variables m_lang below |
| Return: | date without seperators |
| Description: | Remove seperator in date |
| Syntax: | bool dbClose () |
| Return: | true if no errors occurred, otherwise false |
| Description: | disconnect current database connection (change m_db_obj for select the right one, if you use more the one connection) |
| Syntax: | object dbConnect (string db_type, string db_host, string db_name, string db_user [, string password [, bool db_persistent] [, bool mode]]) |
| Options: | db_type = type of database (i.g. mysql, pgsql) db_host = database server, if empty, local connection is used. db_name = name of database db_user = user name to database server db_pass = password to database server db_persistent = true for persistent {default: true} mode = if false, no error message will be printed out {default: true} |
| Return: | PEAR database object |
| Description: | Opens a connection to a database server and select
database Furthermore it sets m_db_obj to the PEAR database object, which is required for dbsession |
| Syntax: | int dbFreeID (string table, string column [, string where_key, string where_value]) |
| Options: | table = database table to use column = database column to use where_key = database column name for limitation {default: void} where_value = limitation value {default: void} |
| Return: | lowest unused number in a column |
| Description: | Get number of lowest unused number in a column) |
| Syntax: | int dbInsertId ([bool mode]) |
| Options: | mode = true for print output {default: false} |
| Return: | id generated from the previous INSERT operation |
| Description: | Get the id generated from the previous INSERT operation |
| Syntax: | int dbNextID (string table, string column [, bool mode]) |
| Options: | table = database table to use column = database column to use mode = true for print output error message {default: false} |
| Return: | highst number in column + 1 |
| Description: | Get next available number |
| Syntax: | string dbsessionsub_start (string session_id [, string session_subid]) |
| Options: | session_id = session id to use (main session) session_subid = session_subid. If empty new unique id will be generated if required |
| Return: | session_subid |
| Required: | read README file |
| Description: | starts sub session within a session. You can use it to group the
session in different parts |
| Syntax: | bool dbsession_delete (string session_id, string var_name) |
| Options: | session_id = session id which will be used for the
variabel var_name = variable to remove |
| Return: | true if successfully removed variable |
| Required: | read README file |
| Description: | unregister variable in dbsession |
| Syntax: | bool dbsession_end ([string session_id]) |
| Options: | session_id = session id which should end ( and expired dbsession will automatically be removed) |
| Return: | true if successfully end dbsession |
| Required: | read README file |
| Description: | ends dbsession or dbsessionsub |
| Syntax: | string dbsession_read (string session_id, string var_name, mixed var_value) |
| Options: | session_id = session id to use, if empty new unique name will be
generated var_name = variable to add var_value = value of variable |
| Return: | value of variable |
| Required: | read README file |
| Description: | register variable in dbsession |
| Syntax: | string dbsession_start ([string session_id]) |
| Options: | session_id = session id to use, if empty new unique id will be generated if required |
| Return: | session_id |
| Required: | read README file |
| Description: | starts dbsession. Enables session fallback handling. This
functions will be required, if you want to handle the session_id with url or formstart |
| Syntax: | string dbsession_write (string session_id, string var_name, mixed var_value) |
| Options: | session_id = session id to use, if empty new unique name will be
generated var_name = variable to add var_value = value of variable |
| Return: | value of variable |
| Required: | read README file |
| Description: | register variable in dbsession |
| Syntax: | string dbVersion ([float mav [, float miv]]) |
| Options: | mav = major release number {default: 3.23} miv = minor release number {default: 6} |
| Return: | active database version, if false empty |
| Description: | check right database version |
| Syntax: | string fileExtension (string filename) |
| Options: | filename = filename to use |
| Return: | file extention (e.g. txt) |
| Description: | return file extension |
| Syntax: | string form_end (void) |
| Description: | close tag for HTML form |
| Syntax: | string form_start (string action [, string name [, string method] [, bool mode]]) |
| Options: | action = action name = name for formular {default: void} method = post or get {default: post} mode = false: no session_id, true: with session_id if required {default: true} customize = for addon parameters like enctype |
| Return: | formular head |
| Description: | begining for formular (this function can only handle the session_id, if dbsession_start has been called immediately after creating the class object) |
| Syntax: | string generatePassword (int minlen, int maxlen, string word_file [, int fillers]) |
| Options: | minlen = min. length of password maxlen = max. length of password word_file = word file for password generation fillers = 1 (less fillers, 2 (more fillers) {default: 1} |
| Return: | generated password string |
| Required: | word file (e.g. word_file.txt, which comes with cphplib package) |
| Description: | generate password from word list and random words with fillers |
| Syntax: | mixed get_user_var (string var_name, string var_type) |
| Options: | var_name = name of variable var_type = type of variable (POST,GET,COOKIE,SESSION or DBSESSION) |
| Return: | value of variable or "", if invalid |
| Description: | returns value of special variable type from user input (If register_globals is Off (default since 4.2.0), this function can be used, to handle user variables (insecure variables). You can use more than one type (seperated with ",") DBSESSION only works if dbsession_start has been called before. |
| Syntax: | bool isvoid (string str [, bool mode]) |
| Options: | str = string to validate mode = true for compatible with echo {default: false} |
| Return: | true if string is empty |
| Description: | replacement for useless PHP echo function |
| Syntax: | string killSpace (string str) |
| Options: | str = string to use |
| Description: | Remove whitespaces in a string |
| Syntax: | bool listNotes (array data [, string header [, string head_style] [, string body_style]]) |
| Options: | data = array with notes header = header string for notes head_style = style class for note header, span {default: hnote} body_style = style class for note data, p {default: enote} |
| Return: | returns true, unless no key of data array starts with "db" (can be used for error diffentation) |
| Description: | output all values in the array (e.g. to list error messages) |
| Syntax: | void metaSearch (string filename) |
| Options: | filename with keywords |
| Required: | every line in filename is a keyword, first line is the
description (first line with quotes!!!) |
| Description: | prints a meta description and meta keywords line for xhtml |
| Syntax: | void newsList (string table,int p_max, bool p_author, string p_tablecolor |
| Options: | p_table = table name (i.e. for more then one country) {default:
news} p_max = max news {default: 20} p_author = show initials of author {default: 0} p_tablecolor = table color p_tablewidth = table width p_headimage = header image p_headcolor = head color p_trcolor = tr color p_tdcolor = td color p_format = see member variables m_lang below |
| Required: | read newlist.txt |
| Description: | news system (details read newlist.txt) |
| Syntax: | char os_type ([bool mode]) |
| Options: | mode = true for server os, false for client os {default: false} |
| Return: | w = Windows m = Mac l = Linux u = Unix o = OS/2 "" = unknown |
| Description: | returns type of operating system |
| Syntax: | string rand_value ([int length [, strint values]) |
| Options: | length = length of chars/numbers for return values = string with all allowed characters/numbers |
| Return: | generated rand string, on error "" |
| Description: | generate rand string/number with specified length |
| Syntax: | int txtCounter (string identify [, bool mode]) |
| Options: | identify = unique name for each page mode = true for reload block {default: false} |
| Return: | number of visitors |
| Required: | tmp directory in document_root with write access for webserver |
| Description: | simple text user counter |
| Syntax: | string url (string url [, string name [, int mode] [, string title] [, string customize]]) |
| Options: | url = url name = name of url {default: url} mode = 0: no session_id 1: with session_id if required {default: 1} 2: just url with session_id (without TAG) title = url title (hover text) customize = other parameters like target, style or class |
| Return: | created url |
| Description: | prints url as html tag (this function can only handle the session_id, if dbsession_start has been called immediately after creating the class object) |
| Syntax: | bool url_on_scripthost (string url) |
| Options: | url = url |
| Return: | true if it is on host |
| Description: | checks if specified url is on script server (on the host where your scripts are) |
| Syntax: | timestamp validate_timestamp (mixed curr_date [, bool mode]) |
| Options: | curr_date = array of date for validating or timestamp array keys: timestamp['year'] timestamp['month'] timestamp['day'] timestamp['hour'] timestamp['minute'] timestamp['second'] mode = if true, input date is a timestamp {default: false} |
| Return: | timestamp with valid date, if invalid input datas, return timestamp
will be return the nearest valid date |
| Description: | validate given date |